import request from '@/utils/request'

const api_name='/admin/system/sysRole'

export default{
    getPageList(page,limit,searchObj){
        return request({
            // url: '/admin/system/sysRole/'+page+'/'+limit,
            url: `${api_name}/${page}/${limit}`,
            method: 'get',
            params: searchObj
          })
    },
    romove(id){
        return request({
            // url: '/admin/system/sysRole/'+page+'/'+limit,
            url: `${api_name}/romove/${id}`,
            method: 'delete',
          
          })
    },
    save(sysRole){
        return request({
            // url: '/admin/system/sysRole/'+page+'/'+limit,
            url: `${api_name}/save`,
            method: 'post',
            data: sysRole
          })
    },
    getByid(id){
        return request({
            // url: '/admin/system/sysRole/'+page+'/'+limit,
            url: `${api_name}/get/${id}`,
            method: 'get',
        
          })
    },
    update(sysRole){
        return request({
            // url: '/admin/system/sysRole/'+page+'/'+limit,
            url: `${api_name}/update`,
            method: 'put',
            data: sysRole
          })
    },
    batchRemove(idlist){
        return request({
            // url: '/admin/system/sysRole/'+page+'/'+limit,
            url: `${api_name}/batchRemove`,
            method: 'delete',
            data: idlist
          })
    },
        //根据用户id查询用户已分配的角色
    getRolesByUserId(userId) {
        return request({
        url: `${api_name}/toAssign/${userId}`,
        method: 'get'
        })
    },
    
    //分配角色
    assignRoles(assginRoleVo) {
        return request({
        url: `${api_name}/doAssign`,
        method: 'post',
        data: assginRoleVo
        })
    }
}

